package com.wf.netty.coder.encoder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import lombok.extern.slf4j.Slf4j;

/**
 * 功能描述
 *
 * @author wf
 * @since 2022/5/26
 */
@Slf4j
@ChannelHandler.Sharable
public class Integer2ByteEncoder extends MessageToByteEncoder<Integer> {
    public static Integer2ByteEncoder INSTANCE = new Integer2ByteEncoder();

    @Override
    public void encode(ChannelHandlerContext ctx, Integer msg, ByteBuf out) throws Exception {
        out.writeInt(msg);
        log.info("encoder Integer, msg is: {}", msg);
    }
}
